const { Breadcrumb, Icon } = antd;
const Top_breadcrumb = React.createClass({
    getInitialState(){
        return({
            data: top_breadcrumb
        });
    },
    urlClick(url){
        window.parent.location.href = url;
    },
    render(){
        let data = this.state.data;
        let baseUrl = document.getElementsByTagName('base')[0].href;
        let home_url = baseUrl + 'index.php/admin/index/index';
        let level1 =
            <Breadcrumb.Item onClick={function(){this.urlClick(baseUrl + data[0].url)}.bind(this)}><a href="javascript:void(0);">{data[0].title}</a></Breadcrumb.Item>;
        let level2 = data[1].title!='null' ? [
            <Breadcrumb.Item onClick={function(){this.urlClick(baseUrl + data[1].url)}.bind(this)}><a href="javascript:void(0);">{data[1].title}</a></Breadcrumb.Item>
        ] : null;
        return(
            <Breadcrumb>
                <Breadcrumb.Item onClick={function(){this.urlClick(home_url)}.bind(this)}>
                    <Icon type="home" /><a href="javascript:void(0);">首页</a>
                </Breadcrumb.Item>
                {level1}
                {level2}
            </Breadcrumb>
        );
    }
});
